package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
//查询购物车是否存在餐品
    List<ShoppingCart> select(ShoppingCart shoppingCart);
//添加购物车餐品数量
    @Update("update shopping_cart set number = number + 1 where id = #{id}")
    void update(Long id);
//购物车添加餐品
    @Insert("insert into shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor, number, amount, create_time) VALUES " +
            "(#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void insert(ShoppingCart shoppingCart);
//清空购物车
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long currentId);
//删除购物车商品
    //数量-1
    void subOne(ShoppingCart shoppingCart);
    //判断数量是否到0
    void check(ShoppingCart shoppingCart);
}
